#@embedLayout()


#define content()

<form id="formId" method="post" enctype="multipart/form-data">
    <table class="table table-bordered">
        <tr>
            <td style="padding-top:15px;">#(_res.get('facet.form.apkfile')):</td>
            <td>
                <input type="file" id="apkFile" name="apkFile" class="easyui-validatebox" style="width:300px;"
                       data-options="required:true" accept=".apk">
            </td>
        </tr>
    </table>
</form>

#end


#define css()


#end


#define js()

<script type="text/javascript">

    function generateFacetId() {
        var url = contextRootPath + '/facet/getFacetIdFromApk';

        $('#formId').form('submit', {
            url: url,
            onSubmit: function () {
                var flag = $(this).form('enableValidation').form('validate');

                var apkFile = $("#apkFile");
                var apkFilePath = apkFile.val().toLocaleLowerCase();
                var lastContent = apkFilePath.substr(apkFilePath.lastIndexOf("."), apkFilePath.length)

                if (lastContent === '') {
                    flag = false;
                    $.messager.alert("提示", "请选择文件", "warning");
                    return flag;
                }


                if (lastContent !== '.apk') {
                    flag = false;
                    $.messager.alert("提示", "上传文件格式不正确", "warning");
                    return flag;
                }

                var fileSize =  document.getElementById('apkFile').files[0]; //获得文件大小；
                console.log("file size:"+fileSize.size);
                if(fileSize.size > 52428800){
                    flag = false;
                    $.messager.alert("提示", "请上传不超过50M的文件", "warning");
                    return flag;
                }


                if (flag) {
                    showProcess(true, '温馨提示', '正在提交数据...');
                }
                return flag;
            },
            success: function (data) {
                showProcess(false);
                var params = {};
                params.element = _datagrid;
                params.data = data;
                resultCallback(params);
            },
            onLoadError: function () {
                showProcess(false);
                $.messager.alert('温馨提示', '由于网络或服务器太忙，提交失败，请重试！');
            }
        });
    }

</script>

#end


